<template>
  <div id="HomePage">
    <div class="home-header">
      <div class="home-header-title">博汇科技超高清体验评测系统</div>
      <div class="home-page-menu-container">
        <div class="menu-toggle" @click="isMenuOpen = !isMenuOpen">
          <i :class="['menu-icon', isMenuOpen ? 'is-open' : '']"></i>
        </div>
        <div class="home-page-menu-list" :class="{ 'is-open': isMenuOpen }">
          <span
            class="home-page-menu-item"
            :class="{ active: activeMenu === 'convergence-system' }"
            @click="goToConvergenceSystem"
            >汇聚系统</span
          >
          <span
            class="home-page-menu-item"
            :class="{ active: activeMenu === 'subjective-evaluation' }"
            @click="goToSubjectiveEvaluation"
            >主观评价</span
          >
          <span
            class="home-page-menu-item"
            :class="{ active: activeMenu === 'objective-evaluation' }"
            >客观评价</span
          >
          <span
            class="home-page-menu-item"
            :class="{ active: activeMenu === 'comprehensive-evaluation' }"
            >综合评价</span
          >
          <span
            v-if="false"
            class="home-page-menu-item"
            :class="{ active: activeMenu === 'system-manage' }"
            @click="goToSystemManage"
            >系统管理</span
          >
        </div>
      </div>
    </div>
    <div class="home-page-content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useRouter } from "vue-router";
import { useRoute } from "vue-router";

const router = useRouter();
const route = useRoute();
const currentRouteName = route.name;

const isMenuOpen = ref(false);
const activeMenu = ref("");
switch (currentRouteName) {
  case "LiveResource":
  case "VodResource":
  case "TerminalResource":
    activeMenu.value = "convergence-system";
    break;
  case "Template":
  case "EvaluateTask":
  case "RecordBack":
    activeMenu.value = "subjective-evaluation";
    break;
  default:
}

const goToConvergenceSystem = () => {
  activeMenu.value = "convergence-system";
  router.push({
    name: "TerminalResource",
  });
};
const goToSubjectiveEvaluation = () => {
  activeMenu.value = "subjective-evaluation";
  router.push({
    name: "Template",
  });
};
const goToSystemManage = () => {
  activeMenu.value = "system-manage";
  router.push({
    name: "UserManage",
  });
};
</script>

<style scoped lang="scss">
#HomePage {
  width: 100%;
  height: 100%;
  background: url("~@/assets/images/bg.png") no-repeat center center;
  background-size: cover;
}
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 8.4rem;
  padding-left: 3rem;
  padding-right: 3rem;
  .home-header-title {
    font-family: "douyinbold";
    font-size: $font-size-system-Logo;
    color: $text-color-brand;
  }

  .home-page-menu-container {
    position: relative;
  }

  .menu-toggle {
    display: none;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    position: relative;

    .menu-icon {
      position: absolute;
      top: 50%;
      left: 0;
      width: 100%;
      height: 2px;
      background-color: $text-color-primary;
      transition: all 1s ease;

      &:before,
      &:after {
        content: "";
        position: absolute;
        width: 100%;
        height: 2px;
        background-color: $text-color-primary;
        transition: all 1s ease;
      }

      &:before {
        top: -8px;
      }

      &:after {
        top: 8px;
      }

      &.is-open {
        background-color: transparent;

        &:before {
          transform: rotate(45deg);
          top: 0;
        }

        &:after {
          transform: rotate(-45deg);
          top: 0;
        }
      }
    }
  }

  .home-page-menu-list {
    display: flex;
    align-items: center;

    .home-page-menu-item {
      margin-left: 6rem;
      padding: 1rem 2rem;
      font-size: $font-size-system-menu;
      color: $text-color-primary;
      cursor: pointer;
      &:hover {
        text-decoration: underline;
      }
    }
    .home-page-menu-item:first-child {
      margin-left: 0;
    }
    .home-page-menu-item.active {
      color: $text-color-white;
      background: url("~@/assets/images/menu-active.png") no-repeat center
        center;
      background-size: 100% 100%;
    }
  }
}

.home-page-content {
  width: 100%;
  height: calc(100% - 8.4rem);
  padding: 0 2rem 1rem;
}

@media (max-width: $breakpoint-lg) {
  .home-header {
    height: 6rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    .home-header-title {
      font-size: 2.4rem;
    }
    .menu-toggle {
      display: block;
    }
    .home-page-menu-list {
      display: none;
      position: absolute;
      top: 100%;
      right: 0;
      width: 12rem;
      flex-direction: column;
      background-color: #fff;
      padding: 1rem;
      border-radius: 0 0 5px 5px;
      box-shadow: 10px;
      z-index: 999;
      border: 1px solid $border-color-primary;

      &.is-open {
        display: flex;
      }

      .home-page-menu-item {
        padding: 0.75rem 1.5rem;
        width: 100%;
        margin-left: 0;
        text-align: center;
        font-size: 1.6rem;
        color: $text-color-primary;
        & {
          border-bottom: 1px solid $border-color-primary;
        }
      }
    }
  }
  .home-page-content {
    height: calc(100% - 6rem);
    padding: 0 1.5rem 1rem;
  }
}
</style>
